package com.barbeque.mall.controller;

import com.barbeque.mall.bean.BaseRespVo;
import com.barbeque.mall.bean.user.MarketPage;
import com.barbeque.mall.service.user.PageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author why
 * @since 2022/07/16 14:28
 * 首页功能
 */
@RestController
@RequestMapping("admin")
public class PageController {

    @Autowired
    PageService pageService;

    @RequestMapping("dashboard")
    public BaseRespVo marketPage(){
//        BaseRespVo<MarketPage> marketPageBaseRespVo = new BaseRespVo<>();
        MarketPage marketPage = new MarketPage();
        int userNum = pageService.selectUserNum();
        int ordersNum =  pageService.selectOrdersNum();
        int productNum =  pageService.selectProductNum();
        int goodsNum =  pageService.selectGoodsNum();
        marketPage.setUserTotal(userNum);
        marketPage.setGoodsTotal(goodsNum);
        marketPage.setOrderTotal(ordersNum);
        marketPage.setProductTotal(productNum);
//        marketPageBaseRespVo.setData(marketPage);
        return BaseRespVo.ok(marketPage);
    }
}
